﻿
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;

namespace GameBoxTools
{
    [CustomEditor(typeof(BaseStatistic), true)]
    public class BaseStatisticEditor : Editor
    {
        public static SerializedProperty orignScene;

        void OnEnable()
        {
            orignScene = serializedObject.FindProperty("orignScene");
        }

        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            if (GUILayout.Button("返回之前场景"))
            {
                string path = orignScene.stringValue;
                if (!string.IsNullOrEmpty(path) && !SceneManager.GetActiveScene().Equals(path))
                {
                    EditorSceneManager.OpenScene(path);
                }
            }
        }
    }
}